<template>
	<div class="member_edit">
		<el-form ref="formDataRef" :model="formData" label-width="120px" class="demo-form-inline">
			<el-row style="margin-bottom: 18px">
				<el-col :span="12">
					<el-form-item prop="firstname" label="姓名" style="width: 100%">
						<el-input style="width: 100%" maxlength="200" v-model="formData.firstname" />
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item prop="lastname" label="姓氏" style="width: 100%">
						<el-input style="width: 100%" maxlength="200" v-model="formData.lastname" />
					</el-form-item>
				</el-col>
			</el-row>
			<el-form-item prop="member_level_id" label="会员级别">
				<el-select style="width: 100%" v-model="formData.memberLevelId" placeholder="选择站点">
					<el-option v-for="item in props.levelList" :key="item.id" :label="item.levelName" :value="item.id"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item prop="commission" label="消费佣金比列">
				<el-input style="width: 100%" v-model="formData.commission" placeholder="请输入消费佣金比列" />
			</el-form-item>
			<el-form-item prop="orderCommiss" label="订单佣金($/单)">
				<el-input style="width: 100%" v-model="formData.orderCommiss" placeholder="请输入订单佣金" />
			</el-form-item>
			<el-form-item prop="recommindZCommission" label="直接佣金比列">
				<el-input style="width: 100%" v-model="formData.recommindZCommission" placeholder="请输入直接佣金比列" />
			</el-form-item>
			<el-form-item prop="recommindJCommission" label="间接佣金比列">
				<el-input style="width: 100%" v-model="formData.recommindJCommission" placeholder="请输入间接佣金比列" />
			</el-form-item>
		</el-form>
	</div>
</template>
<script setup>
import { ElMessage } from 'element-plus';
import { useCustomerApi } from '/@/api/customer';

const { getCustomerDetail } = useCustomerApi();

const props = defineProps(['levelList', 'memberId']);
console.log(props);

const formData = ref({});

async function getDetail() {
	let params = {
		id: props.memberId,
	};
	let res = await getCustomerDetail(params.id);
	if (res.code !== 200) {
		return;
	}
	let item = res.data;
	formData.value = {
		id: item.id,
		name: item.firstname + ' ' + item.lastname,
		firstname: item.firstname,
		lastname: item.lastname,
		memberLevelId: item.memberLevelId,
		commission: item.commission,
		orderCommiss: item.orderCommiss,
		recommindZCommission: item.recommindZCommission,
		recommindJCommission: item.recommindJCommission,
	};
	try {
		console.log(11);
	} catch (error) {
		ElMessage({
			type: 'error',
			message: '获取详情失败',
		});
	}
}

defineExpose({
	formData,
});

onMounted(() => {
	getDetail();
});
</script>
<style lang="scss"></style>
